package com.jeeplus.test.jlnu.qualificationInfo.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.test.jlnu.admissionInfo.domain.entity.AllInfo;
import com.jeeplus.test.jlnu.archivalInfo.domain.entity.ArchParmerter;
import com.jeeplus.test.jlnu.qualificationInfo.domain.entity.QualificationInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface QualificationInfoMapper {

    @Select({
            "<script>",
            "SELECT qu.*,",
            "       ad.archival_num AS archivalNum,",
            "       ad.case_title AS caseTitle,",
            "       ad.file_title AS fileTitle,",
            "       ad.save_location AS saveLocation,",
            "       ad.page_location AS pageLocation,",
            "       ad.page_num AS pageNum,",
            "       ad.examinee_num AS examineeNum,",
            "       ad.admission_num AS admissionNum,",
            "       ad.student_id AS studentId,",
            "       ad.name AS name,",
            "       ad.gender AS gender,",
            "       ad.birthday AS birthday,",
            "       ad.political_outlook AS politicalOutlook,",
            "       ad.nation AS nation,",
            "       ad.id_card AS idCard,",
            "       ad.plan_nature AS planNature,",
            "       ad.admission_schools AS admissionSchools,",
            "       ad.admission_academy AS admissionAcademy,",
            "       ad.admission_major AS admissionMajor,",
            "       ad.admission_time AS admissionTime,",
            "       ad.gradation AS gradation,",
            "       ad.educational_system AS educationalSystem,",
            "       ad.learning_forms AS learningForms,",
            "       ad.examinee_sort AS examineeSort,",
            "       ad.batch AS batch,",
            "       ad.graduation_school AS graduationSchool,",
            "       ad.source_area AS sourceArea,",
            "       ad.area_name AS areaName,",
            "       ad.home_address AS homeAddress,",
            "       ad.postal_code AS postalCode,",
            "       ad.phone_num AS phoneNum,",
            "       ad.info_source AS infoSource,",
            "       ad.remarks AS remarks,",
            "       ad.ext1 AS ext1,",
            "       ad.ext2 AS ext2,",
            "       ad.ext3 AS ext3,",
            "       ad.ext4 AS ext4,",
            "       ad.ext5 AS ext5,",
            "       ad.ext6 AS ext6,",
            "       ad.ext7 AS ext7,",
            "       ad.ext8 AS ext8,",
            "       ad.ext9 AS ext9,",
            "       ad.ext10 AS ext10,",
            "       ad.ext11 AS ext11,",
            "       ad.ext12 AS ext12,",
            "       ad.ext13 AS ext13,",
            "       ad.ext14 AS ext14,",
            "       ad.ext15 AS ext15,",
            "       ad.ext16 AS ext16,",
            "       ad.ext17 AS ext17,",
            "       ad.ext18 AS ext18,",
            "       ad.ext19 AS ext19,",
            "       ad.ext20 AS ext20",
            "FROM jlnu_qualification_info qu",
            "LEFT JOIN jlnu_admission_info ad ON qu.student_id = ad.student_id",
            "WHERE 1=1",
            "<if test='qualificationInfoReqVo.name != null and qualificationInfoReqVo.name != \"\"'>",
            "AND ad.name = #{qualificationInfoReqVo.name}",
            "</if>",
            "<if test='qualificationInfoReqVo.studentId != null and qualificationInfoReqVo.studentId != \"\"'>",
            "AND ad.student_id = #{qualificationInfoReqVo.studentId}",
            "</if>",
            "<if test='qualificationInfoReqVo.admissionAcademy != null and qualificationInfoReqVo.admissionAcademy != \"\"'>",
            "AND ad.admission_academy = #{qualificationInfoReqVo.admissionAcademy}",
            "</if>",
            "<if test='qualificationInfoReqVo.admissionMajor != null and qualificationInfoReqVo.admissionMajor != \"\"'>",
            "AND ad.admission_major = #{qualificationInfoReqVo.admissionMajor}",
            "</if>",
            "<if test='qualificationInfoReqVo.phoneNum != null and qualificationInfoReqVo.phoneNum != \"\"'>",
            "AND ad.phone_num = #{qualificationInfoReqVo.phoneNum}",
            "</if>",
            "</script>"
    })
    Page<QualificationInfo> getQualificationInfoPage(ArchParmerter qualificationInfoReqVo, Page<QualificationInfo> page);
    @Update("UPDATE jlnu_qualification_info SET " +
            "native_place = #{nativePlace}, " +
            "degree_certificate_num = #{degreeCertificateNum}, " +
            "degree_certificate_date = #{degreeCertificateDate}, " +
            "officer_id_num = #{officerIdNum}, " +
            "discipline_major = #{disciplineMajor}, " +
            "degree_type = #{degreeType}, " +
            "study_start_time = #{studyStartTime}, " +
            "study_end_time = #{studyEndTime}, " +
            "document_title = #{documentTitle}, " +
            "document_date = #{documentDate} " +
            "WHERE student_id = #{studentId}")
    int updateQual(QualificationInfo qualificationInfo);

}
